package com.winchain.provider.expiration.cmd;

import com.shell.framework.command.CommandContext;
import com.shell.framework.command.ICommand;
import com.winchain.provider.expiration.po.CbDebit;
import com.winchain.provider.expiration.rx.BillExpirationEvent;
import com.winchain.provider.expiration.service.CbDebitService;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillExpDebitMsgCmd implements ICommand<BillExpirationEvent> {
	@Autowired
	private CbDebitService cbDebitService;

	public boolean execute(CommandContext<BillExpirationEvent> context) throws Exception {
		String expDate = ((BillExpirationEvent) context.getSource()).getDate();

		Map<String, List<CbDebit>> cusDebitsMap = (Map) context.getValue("cusDebitsMap");
		for (String finId : cusDebitsMap.keySet()) {
			this.cbDebitService.sendExpDebitMessage(expDate, finId, (List) cusDebitsMap.get(finId));
		}
		return false;
	}
}
